#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    int maxArea(vector<int>& height) {
        int left = 0;
        int right = height.size() - 1;
        int maxv = 0;
        while (left < right)
        {
            int h = height[left] < height[right] ? height[left] : height[right];
            int v = h * (right - left);
            if (v > maxv)
                maxv = v;
            if (height[left] < height[right])
                left++;
            else
                right--;
        }
        return maxv;
    }
};